/**
 * All rights Reserved
 *
 * @Title: SolrService.java
 * @Package com.amigo.online.provider.sync.abs
 * @Description: (用一句话描述该文件做什么)
 * @author: zxy  QQ:1363320658
 * @date: 2018年12月14日 下午6:54:49
 * @version V1.0
 * @Copyright: 2018  All rights reserved.
 */
package com.amigo.online.provider.sync.abs;

import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrInputDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.stereotype.Service;

/**
 * @version: V 1.0.0
 * @Description: （对类进行功能描述） 
 * @author: zxy  QQ:1363320658
 * @date: 2018年12月14日 下午6:54:49  
 *
 */
@Service
public class SolrService {

    protected final Logger logger = LoggerFactory.getLogger(SolrService.class);

    @Autowired
    SolrTemplate solrTemplate;

    public void insertObject(SolrInputDocument document, String collection) {
        UpdateResponse result = solrTemplate.saveDocument(collection, document);
        solrTemplate.commit(collection);
        logger.info(collection + " solr 插入结果:" + result.toString());
    }

    public long updateObject(SolrInputDocument update, String collection) {
        UpdateResponse result = solrTemplate.saveDocument(collection, update);
        solrTemplate.commit(collection);
        logger.info(collection + " solr 更新结果:" + result.toString());
        return 0;
    }


}
